//
//  WXPHomeCloundReportView.m
//  MexicoLoan
//
//  Created by WXP on 2025/3/10.
//
//

#import "WXPHomeCloundReportView.h"
#import "WXPCreditReportDetailVC.h"

@interface WXPHomeCloundReportView ()

@end

@implementation WXPHomeCloundReportView

#pragma mark - lazy
- (UIImageView *)imageBack
{
    if (_imageBack == nil) {
        _imageBack = [UIImageView  new];
        _imageBack.widthHeight = XY(SCREEN_WIDTH-LEFT_MARDIN*2, (SCREEN_WIDTH-LEFT_MARDIN*2)/343*146);
        _imageBack.image = [UIImage imageNamed:@"icon-home-rainbow"];
        [GlobalMethod setRoundView:_imageBack color:COLOR_LINE numRound:16 width:1];
    }
    return  _imageBack;
}
- (UILabel *)labelTitle
{
    if (_labelTitle == nil) {
        _labelTitle = [UILabel  new];
        _labelTitle.font = [UIFont boldSystemFontOfSize:14];
        _labelTitle.textColor = COLOR_BLACK;
        _labelTitle.numberOfLines = 0;
        _labelTitle.lineSpace = 4;
        [_labelTitle fitTitle:@"Obtener la puntuación utilizada\npor los prestamistas" variable:0];
    }
    return  _labelTitle;
}
- (UILabel *)labelContent
{
    if (_labelContent == nil) {
        _labelContent = [UILabel  new];
        _labelContent.fontNum = 12;
        _labelContent.textColor = COLOR_LIGHT_GRAY;
        _labelContent.numberOfLines = 0;
        _labelContent.lineSpace = 3;
    }
    return  _labelContent;
}
- (UIImageView *)imageMore
{
    if (_imageMore == nil) {
        _imageMore = [UIImageView  new];
        _imageMore.image = [UIImage imageNamed:@"icon-home-rainbow-more"];
        _imageMore.widthHeight = XY(16, 16);
    }
    return  _imageMore;
}

#pragma mark - 初始化
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.width = SCREEN_WIDTH;
        [self addSubView];
        UITapGestureRecognizer * tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
        [self addGestureRecognizer:tapGestureRecognizer];
    }
    return self;
}

//添加subview
- (void)addSubView{
    [self addSubview:self.imageBack];
    [self.imageBack addSubview:self.labelTitle];
    [self.imageBack addSubview:self.labelContent];
    [self.imageBack addSubview:self.imageMore];
    [self resetView];
}

#pragma mark - 手势点击
- (void)tapClick:(UITapGestureRecognizer * )tap{
    [NSObject clickFeedback];
    [self.imageBack addClickAnimate];
    WXPCreditReportDetailVC * vc = [WXPCreditReportDetailVC new];
    vc.type = ENUM_REPORT_CLOUNDUN;
    [Global_Nav pushViewController:vc animated:true];
}

#pragma mark - 刷新view
- (void)resetView{
    self.imageBack.centerXTop = XY(self.width/2, 0);
    self.labelTitle.leftTop = XY(Ratio(15), Ratio(20));
    [self.labelContent fitTitle:@"Saber su puntuación crediticia es beneficioso para solicitar préstamos de manera rápida y justa" variable:self.imageBack.width-Ratio(15)*2];
    self.labelContent.leftTop = XY(Ratio(15), Ratio(96));
    self.imageMore.rightBottom = XY(self.imageBack.width-self.labelTitle.left, self.labelContent.bottom+2);
    
    self.height = self.imageBack.bottom+LEFT_MARDIN;
}

@end
